﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RemoteTestRunner.BusinessLogic.Views;
using RemoteTestRunner.BusinessLogic.Models;

namespace RemoteTestRunner.BusinessLogic.Presenters
{
    public class ApplicationNavigationPresenter : PresenterBase
    {
        IApplicationNavigationView _view;
        //IApplicationNavigationModel _model;
        public ApplicationNavigationPresenter(IApplicationNavigationView view)
        {
            _view = view;
            //_model = model;

            _view.SubscribeEditOptionsRequested(EditOptions);
            _view.SubscribeEditProjectsRequested(EditProjects);
            _view.SubscribeEditTestsRequested(EditTests);
        }

        public override IViewBase View
        {
            get { return _view; }
        }

        public override void Start()
        {
            // nothing to do.
        }

        private void EditProjects(object sender, EventArgs e)
        {
            EditProjectsPresenter presenter = IoC.Container.Resolve<EditProjectsPresenter>();
            presenter.Parent = _view;
            presenter.Start();
            // Show Edit Projects dialog
            //using (ProjectAdmin projectAdmin = new ProjectAdmin(_serviceFacade))
            //{
            //    if (projectAdmin.ShowDialog(this) == DialogResult.OK)
            //    {
            //        _reloadProjectsListener(this, e);
            //    }
            //}
        }

        private void EditTests(object sender, EventArgs e)
        {
            EditTestsPresenter presenter = IoC.Container.Resolve<EditTestsPresenter>();
            presenter.Parent = _view;
            presenter.Start();
            // Show Edit Tests dialog
            //using (TestAdmin testAdmin = new TestAdmin(_serviceFacade))
            //{
            //    if (testAdmin.ShowDialog(this) == DialogResult.OK)
            //    {
            //        _reloadProjectsListener(this, e);
            //    }
            //}
        }

        private void EditOptions(object sender, EventArgs e)
        {
            // Show Edit Options dialog
            OptionsPresenter presenter = IoC.Container.Resolve<OptionsPresenter>();
            presenter.Parent = _view;
            presenter.Start();

            bool useRunnerServiceOrig = RtrSettings.UseRunnerService;
            string serviceUrlOrig = RtrSettings.RunnerServiceUrl;

            //using (Options optionsDlg = new Options())
            //{
            //    if (optionsDlg.ShowDialog(this) == DialogResult.OK)
            //    {
            //        InitializeServiceFacade();
            //    }
            //}
        }


    }
}
